import java.util.Scanner;


public class test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int max=0,xb1=0,xb2=0;
        int min=100,xb3=0,xb4=0;
        int cut=0;
        int[][] a =  new int[5][4];
        for (int i=0;i<5;i++){
            for (int j=0;j<4;j++){
                a[i][j]=in.nextInt();
                if (a[i][j]>max){
                    max=a[i][j];
                    xb1=i;
                    xb2=j;
                }
                if (a[i][j]<min){
                    min=a[i][j];
                    xb3=i;
                    xb4=j;
                }
            }
        }
        System.out.println("max="+max+","+"min="+1);
        a[xb1][xb2]=min;
        a[xb3][xb4]=max;
        for (int i=0;i<5;i++){
            for (int j=0;j<4;j++){
                if (i>2){
                    if (cut==0){
                        System.out.printf("%2d",a[i][j]);
                        cut++;
                    }
                    else {
                        System.out.print(" "+a[i][j]);
                    }
                }
               else{
                    if (cut==0){
                        System.out.printf("%d",a[i][j]);
                        cut++;
                    }
                    else {
                        System.out.print(" "+a[i][j]);
                    }
                }
            }
            if (i<4){
                System.out.println();
            }
            cut=0;
        }

    }
}
